/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package forensicsGUI;

import foremost.foremostInstance;
import javax.swing.table.*;
import java.util.*;

/**
 *
 * @author marc
 */
public class ExecutionTableModel extends AbstractTableModel {

    private String[] columnNames = {"Case #", "Output Directory"};
    private Vector<foremostInstance> instances = new Vector<foremostInstance>();

    public int getColumnCount() {
        return columnNames.length;
    }

    public int getRowCount() {
        return instances.size();
    }

    public String getColumnName(int col) {
        return columnNames[col];
    }

    public Object getValueAt(int row, int col) {
        if (col == 0) {
            return instances.get(row).getCaseNumber();
        }
        if (col == 1) {
            return instances.get(row).getOutputDir();
        }

        return "";
    }

    public Class getColumnClass(int c) {
        return getValueAt(0, c).getClass();
    }

    /*
     * Don't need to implement this method unless your table's
     * editable.
     */
    public boolean isCellEditable(int row, int col) {
        //Note that the data/cell address is constant,
        //no matter where the cell appears onscreen.
        return false;
    }

    /*
     * Don't need to implement this method unless your table's
     * data can change.
     */
    public void setValueAt(Object value, int row, int col) {
        //data[row][col] = value;
        instances.add((foremostInstance) value);
        fireTableDataChanged();
    }

    public void deleteRow(Object row) {

        instances.remove(row);
        super.fireTableDataChanged();
    }
}

